package cn.wolfcode.crm.web.controller;

import cn.wolfcode.crm.domain.DictionaryDetail;
import cn.wolfcode.crm.serivce.IDictionaryDetailService;
import cn.wolfcode.crm.util.JSONResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


@Controller
@RequestMapping("dictionaryDetail")
public class DictionaryDetailController {
    @Autowired
    private IDictionaryDetailService service;

    @RequestMapping("delete")
    @ResponseBody
    public JSONResult delete(Long id) throws Exception {
        try {
            service.deleteByPrimaryKey(id);
            return new JSONResult();
        } catch (Exception e) {
            e.printStackTrace();
            return new JSONResult().mark("明细删除失败....");
        }
    }

    //验证用户名的方法
    @RequestMapping("saveOrUpdate")
    @ResponseBody
    public JSONResult query(DictionaryDetail dictionaryDetail) throws Exception {
        try {
            service.saveOrUpdate(dictionaryDetail);
            return new JSONResult();
        } catch (Exception e) {
            e.printStackTrace();
            return new JSONResult().mark("明细更新/保存失败....");
        }
    }

}
